//package com.lwc.config;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.web.WebApplicationInitializer;
//import org.springframework.web.context.ContextLoaderListener;
//import org.springframework.web.filter.CharacterEncodingFilter;
//import org.springframework.web.servlet.DispatcherServlet;
//
//import javax.servlet.DispatcherType;
//import javax.servlet.FilterRegistration;
//import javax.servlet.ServletContext;
//import javax.servlet.ServletException;
//import javax.servlet.ServletRegistration;
//import java.util.EnumSet;
//
///**
// * Created by liwancheng on 2016/10/10.
// */
//@Slf4j
//public class WebInitializer implements WebApplicationInitializer {
//
//    @Override
//    public void onStartup(ServletContext servletContext) throws ServletException {
//        servletContext.addListener(ContextLoaderListener.class);
//        servletContext.setInitParameter("contextConfigLocation", "classpath:spring-context.xml");
//
//        registerFilter(servletContext);
//        registerDispatcherServlet(servletContext);
//    }
//
//    private void registerFilter(ServletContext servletContext) {
//        FilterRegistration.Dynamic encodingFilter = servletContext.addFilter("encodingFilter", new CharacterEncodingFilter());
//        encodingFilter.setInitParameter("encoding", "UTF-8");
//        encodingFilter.setInitParameter("forceEncoding", "true");
//        encodingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), true, "/*");
//        log.info("encoding filter init finished.");
//    }
//
//    private void registerDispatcherServlet(ServletContext servletContext) {
//        ServletRegistration.Dynamic registration = servletContext.addServlet("dispatcherServlet", new DispatcherServlet());
//        registration.setInitParameter("contextConfigLocation", "");
//        registration.setLoadOnStartup(1);
//        registration.addMapping("/");
//        log.info("dispatcher servlet init finished.");
//    }
//}
